﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEditor;
using UnityEditor.Build.Reporting;

namespace zframe.editor
{


    public class BuildPlayerTool
    {
        //以编程的方式发布项目
        [MenuItem("zframe/BuildPlayers/windows")]
        static void BuildWin()
        {
            BuildPlayerOptions opt = new BuildPlayerOptions();
            opt.scenes = new string[] { "Assets/scenes/Main.unity" };
            opt.locationPathName = "win64Build/myBuild.exe";
            opt.target = BuildTarget.StandaloneWindows;
            
            //ShowBuiltPlayer 就是打开构建的路径
            opt.options = BuildOptions.AutoRunPlayer | BuildOptions.ShowBuiltPlayer;
            
            BuildByOption(opt);

        }

        static void BuildByOption(BuildPlayerOptions opt)
        {
            BuildReport report = BuildPipeline.BuildPlayer(opt);
            BuildSummary summary = report.summary;
            Debug.Log("summary.result=" + summary.result);
        }


    }
}
